package com.example.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.domain.BusFriendGroup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
* @author CETC
* @description 针对表【bus_friend_group_1】的数据库操作Mapper
* @createDate 2025-11-05 09:04:57
* @Entity com.example.domain.BusFriendGroup1
*/
public interface BusFriendGroupMapper extends BaseMapper<BusFriendGroup> {

    @Select({"<script>" +
            "   SELECT * FROM ${tableName} WHERE user_id = #{userId} and is_deleted='0' order by create_time desc" +
            "</script>"})
    public IPage<BusFriendGroup> getPage(Page<BusFriendGroup> page, @Param("tableName")String tableName, @Param("userId")String userId);

    @Select("SELECT count(1) FROM ${tableName} WHERE  user_id=#{userId} and friend_uid=#{friendUid} and is_deleted='0'")
    public int getBusFriendGroupCount(@Param("tableName")String tableName,@Param("userId")String userId,@Param("friendUid")String friendUid);


    @Update("UPDATE ${tableName} SET is_deleted='1',update_time = NOW() WHERE uuid = #{uuid}")
    public int deleteBusFriendGroup(@Param("tableName")String tableName,@Param("uuid")String uuid);

    @Update("<script>" +
            "   UPDATE ${tableName} " +
            "       SET is_deleted = '1' " +
            "   WHERE uuid IN " +
            "       <foreach collection='ids' item='id' open='(' close=')' separator=','>" +
            "           #{id}" +
            "       </foreach>" +
            "</script>")
    int batchDeleteDataByIds(@Param("tableName")String tableName,@Param("ids") List<String> ids);
}




